<?php
namespace Home\Controller;
use Think\Controller;
header("Content-type:text/html;charset=utf-8");
class IndexController extends Controller {
    public function index(){
        $this->display();
    }
	public function activity(){
		$this->display();
	}
//发现轮播
	public function  newWinners(){
		$r1 = M("lottery_add la")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on la.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on la.lotteryclass=c.id")
				->where("la.zong_money>0")
				->field("la.uid,la.lotteryclass,la.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,la.ctime,c.name")
				->select();
		$r2 = M("lottery_ssc ls")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on ls.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on ls.lotteryclass=c.id")
				->where("ls.zong_money>0")
				->field("ls.uid,ls.lotteryclass,ls.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,ls.ctime,c.name")
				->select();
		$r3 = M("lottery_pk10 lp")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on lp.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on lp.lotteryclass=c.id")
				->where("lp.zong_money>0")
				->field("lp.uid,lp.lotteryclass,lp.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,lp.ctime,c.name")
				->select();
		$r4 = M("lottery_kl8 lk")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on lk.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on lk.lotteryclass=c.id")
				->where("lk.zong_money>0")
				->field("lk.uid,lk.lotteryclass,lk.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,lk.ctime,c.name")
				->select();
		$r5 = M("lottery_11x5 l1")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on l1.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on l1.lotteryclass=c.id")
				->where("l1.zong_money>0")
				->field("l1.uid,l1.lotteryclass,l1.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,l1.ctime,c.name")
				->select();
		$r6 = M("lottery_fc3d lf")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on lf.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on lf.lotteryclass=c.id")
				->where("lf.zong_money>0")
				->field("lf.uid,lf.lotteryclass,lf.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,lf.ctime,c.name")
				->select();
		$r7 = M("zhui_kl8 zk")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on zk.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on zk.lotteryclass=c.id")
				->where("zk.zo_money>0")
				->field("zk.uid,zk.lotteryclass,zk.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zk.ctime,c.name")
				->select();
		$r8 = M("zhui_pk10 zp")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on zp.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on zp.lotteryclass=c.id")
				->where("zp.zo_money>0")
				->field("zp.uid,zp.lotteryclass,zp.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zp.ctime,c.name")
				->select();
		$r9 = M("zhui_ssc zs")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on zs.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on zs.lotteryclass=c.id")
				->where("zs.zo_money>0")
				->field("zs.uid,zs.lotteryclass,zs.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zs.ctime,c.name")
				->select();
		$r10 = M("zhui_x5 zx")
				->join(" join ".C("DB_PREFIX")."accountsinfo a on zx.uid=a.userid")
				->join(" join ".C("DB_PREFIX")."lottery_class c on zx.lotteryclass=c.id")
				->where("zx.zo_money>0")
				->field("zx.uid,zx.lotteryclass,zx.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zx.ctime,c.name")
				->select();
		$r = array_merge($r1,$r2,$r3,$r4,$r5,$r6,$r7,$r8,$r9,$r10);
		$this->assign("r",$r);
		$this->display();
	}
//发现 详情
	public function playHome(){
		$uid = I("uid");
		if($uid) {
			$r1 = M("lottery_add la")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on la.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on la.lotteryclass=c.id")
					->where("la.zong_money>0 and la.uid={$uid}")
					->field("la.uid,la.lotteryclass,la.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,la.ctime,c.name")
					->select();
			$r2 = M("lottery_ssc ls")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on ls.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on ls.lotteryclass=c.id")
					->where("ls.zong_money>0 and ls.uid={$uid}")
					->field("ls.uid,ls.lotteryclass,ls.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,ls.ctime,c.name")
					->select();
			$r3 = M("lottery_pk10 lp")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on lp.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on lp.lotteryclass=c.id")
					->where("lp.zong_money>0 and lp.uid={$uid}")
					->field("lp.uid,lp.lotteryclass,lp.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,lp.ctime,c.name")
					->select();
			$r4 = M("lottery_kl8 lk")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on lk.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on lk.lotteryclass=c.id")
					->where("lk.zong_money>0 and lk.uid={$uid}")
					->field("lk.uid,lk.lotteryclass,lk.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,lk.ctime,c.name")
					->select();
			$r5 = M("lottery_11x5 ll")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on ll.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on ll.lotteryclass=c.id")
					->where("ll.zong_money>0 and ll.uid={$uid}")
					->field("ll.uid,ll.lotteryclass,ll.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,ll.ctime,c.name")
					->select();
			$r6 = M("lottery_fc3d lf")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on lf.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on lf.lotteryclass=c.id")
					->where("lf.zong_money>0 and lf.uid={$uid}")
					->field("lf.uid,lf.lotteryclass,lf.zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,lf.ctime,c.name")
					->select();
			$r7 = M("zhui_kl8 zk")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on zk.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on zk.lotteryclass=c.id")
					->where("zk.zo_money>0 and zk.uid={$uid}")
					->field("zk.uid,zk.lotteryclass,zk.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zk.ctime,c.name")
					->select();
			$r8 = M("zhui_pk10 zp")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on zp.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on zp.lotteryclass=c.id")
					->where("zp.zo_money>0 and zp.uid={$uid}")
					->field("zp.uid,zp.lotteryclass,zp.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zp.ctime,c.name")
					->select();
			$r9 = M("zhui_ssc zs")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on zs.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on zs.lotteryclass=c.id")
					->where("zs.zo_money>0 and zs.uid={$uid}")
					->field("zs.uid,zs.lotteryclass,zs.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zs.ctime,c.name")
					->select();
			$r10 = M("zhui_x5 zx")
					->join(" join " . C("DB_PREFIX") . "accountsinfo a on zx.uid=a.userid")
					->join(" join " . C("DB_PREFIX") . "lottery_class c on zx.lotteryclass=c.id")
					->where("zx.zo_money>0 and zx.uid={$uid}")
					->field("zx.uid,zx.lotteryclass,zx.zo_money as zong_money,a.sex,a.accounts,a.score,a.avatar,a.nickname,zx.ctime,c.name")
					->select();
		}
		$r = array_merge($r1,$r2,$r3,$r4,$r5,$r6,$r7,$r8,$r9,$r10);
		$tu1 = array();
		foreach($r as $v){
			$tu1= $v['uid'];
			$accounts = $v['accounts'];
			$nickname = $v['nickname'];
			$avatar = $v['avatar'];
		}

		if($tu1){
			$where1 = "uid in ($tu1)";
			$sum11 = M("lottery_add")->where($where1)->select();
			$sum21 = M("lottery_ssc")->where($where1)->select();
			$sum31 = M("lottery_pk10")->where($where1)->select();
			$sum41 = M("lottery_kl8")->where($where1)->select();
			$sum51 = M("lottery_11x5")->where($where1)->select();
			$sum61 = M("lottery_fc3d")->where($where1)->select();
			$sum71 = M("zhui_kl8")->where($where1)->select();
			$sum81 = M("zhui_pk10")->where($where1)->select();
			$sum91 = M("zhui_ssc")->where($where1)->select();
			$sum101 = M("zhui_x5")->where($where1)->select();
		}
		$r2 = array_merge($sum11,$sum21,$sum31,$sum41,$sum51,$sum61,$sum71,$sum81,$sum91,$sum101);
         foreach($r2 as $v){
			 $lotteryclass[] = $v['lotteryclass'];
		 }
         $cai = implode(",",$lotteryclass);

		if($cai){
			$caizhong = M("lottery_class")->where("id in($cai)")->field("id,name")->select();
		}

		$cai_wan = array(
			'1' =>0, //时时彩
			'2' =>0,//快3
			'3' =>0,//PK10
			'4' =>0,//快乐8
			'5' =>0,//排列3
			'6' =>0,//福彩3D
			'7' =>0,//11选5
		);
		foreach($caizhong as $v){
			if(in_array($v['id'],array(15,17,18,19))){
				$cai_wan[1] = 1;
			}elseif(in_array($v['id'],array(1,2,3,4,5,6,7,8,9,10,11,12,13))){
				$cai_wan[2] = 1;
			}elseif(in_array($v['id'],array(21))){
				$cai_wan[3] = 1;
			}elseif(in_array($v['id'],array(20))){
				$cai_wan[4] = 1;
			}elseif(in_array($v['id'],array(27))){
				$cai_wan[5] = 1;
			}elseif(in_array($v['id'],array(26))){
				$cai_wan[6] = 1;
			}elseif(in_array($v['id'],array(22,23,24,25))){
				$cai_wan[7] = 1;
			}
		}

		foreach($r as $ka1=>$va){
			$total = 0;//总
			foreach ($sum11 as $key1 => $value1) {
				if($va['uid']==$value1['uid']){
					$total+=$value1['zong_money'];
				}
			}
			foreach ($sum21 as $key21 => $value21) {
				if($va['uid']==$value21['uid']){
					$total+=$value21['zong_money'];
				}
			}
			foreach ($sum31 as $key31 => $value31) {
				if($va['uid']==$value31['uid']){
					$total+=$value31['zong_money'];
				}
			}
			foreach ($sum41 as $key41 => $value41) {
				if($va['uid']==$value41['uid']){
					$total+=$value41['zong_money'];
				}
			}
			foreach ($sum51 as $key51 => $value51) {
				if($va['uid']==$value51['uid']){
					$total+=$value51['zong_money'];
				}
			}
			foreach ($sum61 as $key61 => $value61) {
				if($va['uid']==$value61['uid']){
					$total+=$value61['zong_money'];
				}
			}
			foreach ($sum71 as $key71 => $value71) {
				if($va['uid']==$value71['uid']){
					$total+=$value71['zo_money'];
				}
			}
			foreach ($sum81 as $key81 => $value81) {
				if($va['uid']==$value81['uid']){
					$total+=$value81['zo_money'];
				}
			}
			foreach ($sum91 as $key91 => $value91) {
				if($va['uid']==$value91['uid']){
					$total+=$value91['zo_money'];
				}
			}
			foreach ($sum101 as $key101 => $value101) {
				if($va['uid']==$value101['uid']){
					$total+=$value101['zo_money'];
				}
			}

			if($va['score'] < '10'){
				$touxie = 'VIP1'; //级别
				$zhiw = "农民";   //头衔
			}elseif('10' <= $va['score'] && $va['score'] < '200'){
				$touxie = 'VIP2';
				$zhiw = "地主";
			}elseif('200' <= $va['score'] && $va['score'] < '1000'){
				$touxie = 'VIP3';
				$zhiw = "知县";
			}elseif('1000' <= $va['score'] && $va['score'] < '10000'){
				$touxie = 'VIP4';
				$zhiw = "通判";
			}elseif('10000' <= $va['score'] && $va['score'] < '50000'){
				$touxie = 'VIP5';
				$zhiw = "知府";
			}elseif('50000' <= $va['score'] && $va['score'] < '250000'){
				$touxie = 'VIP6';
				$zhiw = "总督";
			}elseif('250000' <= $va['score'] && $va['score'] < '1000000'){
				$touxie = 'VIP7';
				$zhiw = "巡抚";
			}elseif('1000000' <= $va['score'] && $va['score'] < '5000000'){
				$touxie = 'VIP8';
				$zhiw = "丞相";
			}elseif('5000000' <= $va['score']){
				$touxie = 'VIP9';
				$zhiw = "帝王";
			}
			if($va['sex']=='1'){
				$sex = "男"; //性别
			}if($va['sex']=='2'){
				$sex = "女";
			}if($va['sex']=='3'){
				$sex = "保密";
			}
		}

		$this->assign("uid",$uid);
        $this->assign("cai_wan",$cai_wan);
        $this->assign("avatar",$avatar);
		$this->assign("accounts",$accounts);
		$this->assign("nickname",$nickname);
		$this->assign("sex",$sex);
		$this->assign("zhiw",$zhiw);
		$this->assign("touxie",$touxie);
		$this->assign("total",$total);
		$this->assign("r",$r);
		$this->display();
	}
//昨日奖金榜
	public function competition(){
		$data = M('Accountsinfo')
				->field("userid,nickname,avatar,accounts,sex,score")
				->select();
		$tu = array();
		foreach($data as $kk=>$vv){
			$tu[] = $vv['userid'];
		}
		$tus = implode(",",$tu);
		$start = strtotime(date("Y-m-d",strtotime("-1 day"))." 00:00:00");
		$end = strtotime(date("Y-m-d",strtotime("-1 day"))." 23:59:59");
		if($tus){
			$where = "uid in($tus) and ctime >= $start and ctime <= $end";
			$sum1 = M("lottery_add la")->where($where)->select();
			$sum2 = M("lottery_ssc ls")->where($where)->select();
			$sum3 = M("lottery_pk10")->where($where)->select();
			$sum4 = M("lottery_kl8")->where($where)->select();
			$sum5 = M("lottery_11x5")->where($where)->select();
			$sum6 = M("lottery_fc3d")->where($where)->select();
			$sum7 = M("zhui_kl8")->where($where)->select();
			$sum8 = M("zhui_pk10")->where($where)->select();
			$sum9 = M("zhui_ssc")->where($where)->select();
			$sum10 = M("zhui_x5")->where($where)->select();
			$where1 = "uid in($tus)";
			$sum11 = M("lottery_add")->where($where1)->select();
			$sum21 = M("lottery_ssc")->where($where1)->select();
			$sum31 = M("lottery_pk10")->where($where1)->select();
			$sum41 = M("lottery_kl8")->where($where1)->select();
			$sum51 = M("lottery_11x5")->where($where1)->select();
			$sum61 = M("lottery_fc3d")->where($where1)->select();
			$sum71 = M("zhui_kl8")->where($where1)->select();
			$sum81 = M("zhui_pk10")->where($where1)->select();
			$sum91 = M("zhui_ssc")->where($where1)->select();
			$sum101 = M("zhui_x5")->where($where1)->select();
		}

		foreach($data as $ka=>$va){
			$total = 0;//总
			$zuo = 0;//昨日
			foreach ($sum1 as $key => $value) {
				if($va['userid']==$value['uid']){
					$zuo+=$value['zong_money'];
				}
			}
			foreach ($sum2 as $key2 => $value2) {
				if($va['userid']==$value2['uid']){
					$zuo+=$value2['zong_money'];
				}
			}
			foreach ($sum3 as $key3 => $value3) {
				if($va['userid']==$value3['uid']){
					$zuo+=$value3['zong_money'];
				}
			}
			foreach ($sum4 as $key4 => $value4) {
				if($va['userid']==$value4['uid']){
					$zuo+=$value4['zong_money'];
				}
			}
			foreach ($sum5 as $key5 => $value5) {
				if($va['userid']==$value5['uid']){
					$zuo+=$value5['zong_money'];
				}
			}
			foreach ($sum6 as $key6 => $value6) {
				if($va['userid']==$value6['uid']){
					$zuo+=$value6['zong_money'];
				}
			}
			foreach ($sum7 as $key7 => $value7) {
				if($va['userid']==$value7['uid']){
					$zuo+=$value7['zo_money'];
				}
			}
			foreach ($sum8 as $key8 => $value8) {
				if($va['userid']==$value8['uid']){
					$zuo+=$value8['zo_money'];
				}
			}
			foreach ($sum9 as $key9 => $value9) {
				if($va['userid']==$value9['uid']){
					$zuo+=$value9['zo_money'];
				}
			}
			foreach ($sum10 as $key10 => $value10) {
				if($va['userid']==$value10['uid']){
					$zuo+=$value10['zong_money'];
				}
			}
			foreach ($sum11 as $key1 => $value1) {
				if($va['userid']==$value1['uid']){
					$total+=$value1['zong_money'];
				}
			}
			foreach ($sum21 as $key21 => $value21) {
				if($va['userid']==$value21['uid']){
					$total+=$value21['zong_money'];
				}
			}
			foreach ($sum31 as $key31 => $value31) {
				if($va['userid']==$value31['uid']){
					$total+=$value31['zong_money'];
				}
			}
			foreach ($sum41 as $key41 => $value41) {
				if($va['userid']==$value41['uid']){
					$total+=$value41['zong_money'];
				}
			}
			foreach ($sum51 as $key51 => $value51) {
				if($va['userid']==$value51['uid']){
					$total+=$value51['zong_money'];
				}
			}
			foreach ($sum61 as $key61 => $value61) {
				if($va['userid']==$value61['uid']){
					$total+=$value61['zong_money'];
				}
			}
			foreach ($sum71 as $key71 => $value71) {
				if($va['userid']==$value71['uid']){
					$total+=$value71['zo_money'];
				}
			}
			foreach ($sum81 as $key81 => $value81) {
				if($va['userid']==$value81['uid']){
					$total+=$value81['zo_money'];
				}
			}
			foreach ($sum91 as $key91 => $value91) {
				if($va['userid']==$value91['uid']){
					$total+=$value91['zo_money'];
				}
			}
			foreach ($sum101 as $key101 => $value101) {
				if($va['userid']==$value101['uid']){
					$total+=$value101['zong_money'];
				}
			}
			$data[$ka]['zuo_money'] = $zuo;
			$data[$ka]['total'] = $total;

			if($va['score'] < '10'){
				$touxie = 'VIP1';
				$zhiw = "农民";
			}elseif('10' <= $va['score'] && $va['score'] < '200'){
				$touxie = 'VIP2';
				$zhiw = "地主";
			}elseif('200' <= $va['score'] && $va['score'] < '1000'){
				$touxie = 'VIP3';
				$zhiw = "知县";
			}elseif('1000' <= $va['score'] && $va['score'] < '10000'){
				$touxie = 'VIP4';
				$zhiw = "通判";
			}elseif('10000' <= $va['score'] && $va['score'] < '50000'){
				$touxie = 'VIP5';
				$zhiw = "知府";
			}elseif('50000' <= $va['score'] && $va['score'] < '250000'){
				$touxie = 'VIP6';
				$zhiw = "总督";
			}elseif('250000' <= $va['score'] && $va['score'] < '1000000'){
				$touxie = 'VIP7';
				$zhiw = "巡抚";
			}elseif('1000000' <= $va['score'] && $va['score'] < '5000000'){
				$touxie = 'VIP8';
				$zhiw = "丞相";
			}elseif('5000000' <= $va['score']){
				$touxie = 'VIP9';
				$zhiw = "帝王";
			}
			$data[$ka]['touxie'] = $touxie;
			$data[$ka]['zhiw'] = $zhiw;
			if($va['sex']=='1'){
				$sex = "男";
			}if($va['sex']=='2'){
				$sex = "女";
			}if($va['sex']=='3'){
				$sex = "保密";
			}
			$data[$ka]['sex'] = $sex;
		}
		$ages = array();
		foreach ($data as $user) {
			$ages[] = $user['zuo_money'];
		}
		array_multisort($ages, SORT_DESC, $data);
		$da = array_slice($data,0,10);//昨日奖金榜就取前十条信息

		$this->assign("da",$da);
		$this->display();
	}
//晋级奖励
	public function upgrade(){
		if($_POST){
			$id = $_SESSION['user_id'];
			if($id){
				$Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money")->find();
			}
			$type = I("type");
			$up = M('up_level')->where("uid = {$id} and type={$type}")->field("is_lingqu")->find();
			if($up['is_lingqu'] == 1){
				echo 2;die;
			}

				//晋级奖励
				$jiangjin = I("jiangjin");
				$dat0['kl_money'] = $jiangjin;
				$dat0['is_lingqu'] = 1;
				$dat0['lq_time'] = time();
				M("up_level")->where("uid={$id} and type={$type}")->save($dat0);
				$money = $jiangjin;
				//晋级奖励改变money
				$up_level = M('up_level')->where("uid = {$id} and type={$type}")->find();
				$dat1['money'] = $Accountsinfo['money'] + $up_level['kl_money'];

				M('Accountsinfo')->where("userid = {$id}")->save($dat1);
				$date11 = M('Accountsinfo')->where("userid = {$id}")->find();

				$cp['number'] = date("Ymd") . rand(100000, 999999);
				$cp['type'] = '7';
				$cp['shou_money'] = $jiangjin;
				$cp['zhi_money'] = 0;
				$cp['ky_money'] = $date11['money'];
				$cp['ctime'] = time();
				$cp['uid'] = $id;
				$cp['remark'] = '活动礼金';
				M("jiaoyi")->add($cp);
				echo 1, $money;
		}else{
			$id = $_SESSION['user_id'];
			//晋级奖励
			if($id==""){

			}else {
				$up_level = M('up_level')->where("uid = {$id} and type='1'")->find();
			}
			$this->assign("id",$id);
			$this->assign("arr",$up_level);
			$this->display();
		}
	}
//每日加奖
	public function dailyPrise(){
		$id = $_SESSION['user_id'];
		if($id==""){

		}else {
			$up_level = M('up_level')->where("uid = {$id} and type='2'")->find();
		}

//每日加奖
		//条件
		$where = array();
		$where['uid'] = $id;
		$stime = date('Y-m-d',strtotime('-1 day'))." 00:00:00";//昨天开始时间
		$etime = date('Y-m-d',strtotime('-1 day'))." 23:59:59";//昨天结束时间
		$stimes = strtotime($stime);
		$etimes = strtotime($etime);
		$where['ctime'] = array(array('egt',$stimes),array('elt',$etimes));
		//查表
		$data1 = M('lottery_add')->where($where) ->select();
		$data2 = M('lottery_11x5')->where($where)->select();
		$data3 = M('lottery_fc3d')->where($where)->select();
		$data4 = M('lottery_kl8')->where($where) ->select();
		$data5 = M('lottery_pk10')->where($where)->select();
		$data6 = M('lottery_ssc')->where($where)->select();
		$data = array_merge($data1,$data2,$data3,$data4,$data5,$data6);
		$touzhus = 0;   //投注钱数
		foreach($data as $v){
			$touzhus += $v["money"];
		}
		$touzhu = sprintf("%.2f", $touzhus);

		//加奖比例
		$bili = 0;
		if($up_level['level']=='3' && '100'<=$touzhu){
			$bili = 0.6;
		}elseif($up_level['level']=='4' && '100'<=$touzhu){
			$bili = 0.7;
		}elseif($up_level['level']=='5' && '100'<=$touzhu){
			$bili = 0.8;
		}elseif($up_level['level']=='6' && '100'<=$touzhu){
			$bili = 0.9;
		}elseif($up_level['level']=='7' && '100'<=$touzhu){
			$bili = 0.10;
		}elseif($up_level['level']=='8' && '100'<=$touzhu){
			$bili = 1.1;
		}elseif($up_level['level']=='9' && '100'<=$touzhu){
			$bili = 1.2;
		}

		//可得嘉奖
		$jiajiang = 0;
		if($up_level['level']=='3' && '100'<=$touzhu){
			$jiajiang1 = $touzhu * 0.006;
			$jiajiang  = sprintf("%.2f", $jiajiang1);
		}elseif($up_level['level']=='4' && '100'<=$touzhu){
			$jiajiang2 = $touzhu * 0.007;
			$jiajiang  = sprintf("%.2f", $jiajiang2);
		}elseif($up_level['level']=='5' && '100'<=$touzhu){
			$jiajiang3 = $touzhu * 0.008;
			$jiajiang  = sprintf("%.2f", $jiajiang3);
		}elseif($up_level['level']=='6' && '100'<=$touzhu){
			$jiajiang4 = $touzhu * 0.009;
			$jiajiang  = sprintf("%.2f", $jiajiang4);
		}elseif($up_level['level']=='7' && '100'<=$touzhu){
			$jiajiang5 = $touzhu * 0.010;
			$jiajiang  = sprintf("%.2f", $jiajiang5);
		}elseif($up_level['level']=='8' && '100'<=$touzhu){
			$jiajiang6 = $touzhu * 0.011;
			$jiajiang  = sprintf("%.2f", $jiajiang6);
		}elseif($up_level['level']=='9' && '100'<=$touzhu){
			$jiajiang7 = $touzhu * 0.012;
			$jiajiang  = sprintf("%.2f", $jiajiang7);
		}

		$this->assign("jiajiang",$jiajiang);
		$this->assign("bili",$bili);
		$this->assign("touzhu",$touzhu);
		$this->assign("arr",$up_level);
		$this->assign("id",$id);
		$this->display();
	}
//欢乐送
	public function huanlesong(){
		if($_POST){
			$id = $_SESSION['user_id'];
			if($id){
				$Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money")->find();
			}
			$type = I("type");

			$up = M('up_level')->where("uid = {$id} and type={$type}")->field("is_lingqu")->find();
			if($up['is_lingqu'] == 1){
				echo 2;die;
			}

			$jiangjin123 = I("jiangjin123");
			$dat2['kl_money'] = $jiangjin123;
			$dat2['is_lingqu'] = 1;
			$dat2['lq_time'] = time();
			M("up_level")->where("uid={$id} and type={$type}")->save($dat2);
			//每天欢乐颂改变money
			$up_level1 = M('up_level')->where("uid = {$id} and type={$type}")->find();
			$dat3['money'] = $Accountsinfo['money'] + $up_level1['kl_money'];
			M('Accountsinfo')->where("userid = {$id}")->save($dat3);
			$date11 = M('Accountsinfo')->where("userid = {$id}")->find();
			$cp['number'] = date("Ymd").rand(100000,999999);
			$cp['type'] = '7';
			$cp['shou_money'] = $jiangjin123;
			$cp['zhi_money'] = 0;
			$cp['ky_money'] = $date11['money'];
			$cp['ctime'] = time();
			$cp['uid'] = $id;
			$cp['remark'] = '活动礼金';
			M("jiaoyi")->add($cp);

			$money = $jiangjin123;
			echo 1,$money;
		}else{
			$id = $_SESSION['user_id'];
//每天欢乐颂
			if($id==""){

			}else {
				$up_level1 = M('up_level')->where("uid = {$id} and type='3'")->find();
			}
			if($id){
				$Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money,birth")->find();
			}

			//今日投注
			//条件
			$where1 = array();
			$where1['uid'] = $id;
			$stime1 = date('Y-m-d',time())." 09:30:00";//当天开始时间
			$etime1 = date('Y-m-d',time())." 23:50:00";//当天结束时间
			$stimes1 = strtotime($stime1);
			$etimes1 = strtotime($etime1);
			$where1['ctime'] = array(array('egt',$stimes1),array('elt',$etimes1));
			//查表
			$data11 = M('lottery_add')->where($where1) ->select();
			$data21 = M('lottery_11x5')->where($where1)->select();
			$data31 = M('lottery_fc3d')->where($where1)->select();
			$data41 = M('lottery_kl8')->where($where1) ->select();
			$data51 = M('lottery_pk10')->where($where1)->select();
			$data61 = M('lottery_ssc')->where($where1)->select();
			$data1 = array_merge($data11,$data21,$data31,$data41,$data51,$data61);
			$touzhus1 = 0;   //投注钱数
			foreach($data1 as $v){
				$touzhus1 += $v["money"];
			}
			$touzhu1 = sprintf("%.2f", $touzhus1);

			//可得奖金 begion
			if( '888'<= $touzhu1 &&  $touzhu1< '8888' && $Accountsinfo['money'] > '88'){
				$jiang_jin = 8.00;
			}elseif( '8888'<= $touzhu1 && $touzhu1< '88888'  && $Accountsinfo['money'] > '888'){
				$jiang_jin = 58.00;
			}elseif($touzhu1 >= '88888' && $Accountsinfo['money'] > '8888'){
				$jiang_jin = 388.00;
			};
			$jiang_jins= sprintf("%.2f", $jiang_jin);
			$this->assign("arr1",$up_level1);
			$this->assign("jiang_jins",$jiang_jins);
			$this->assign("Accountsinfo",$Accountsinfo);
			$this->assign("touzhu1",$touzhu1);
			$this->assign("id",$id);
			$this->display();
		}
	}
//先到先得
   public function xiandaoxiande(){
	   if($_POST){
		   $id = $_SESSION['user_id'];
		   if($id){
			   $Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money")->find();
		   }
		   $type = I("type");

		   $up = M('up_level')->where("uid = {$id} and type={$type}")->field("is_lingqu")->find();
			 if($up['is_lingqu'] == 1){
				 echo 2;die;
			 }

//先到先得奖励
		   $hong= rand(5,28);
		   $dd['uid'] = $id;
		   $dd['lq_money'] = $hong;
		   $dd['lq_time'] = time();
		   $dat6['kl_money'] = $hong;
		   $dat6['is_lingqu'] = 1;
		   $dat6['lq_time'] = time();
		   M("firstcome")->add($dd);
		   M("up_level")->where("uid={$id} and type={$type}")->save($dat6);
		   //先到先得改变money
		   $up_level3 = M('up_level')->where("uid = {$id} and type={$type}")->find();
		   $dat7['money'] = $Accountsinfo['money'] + $up_level3['kl_money'];
		   M('Accountsinfo')->where("userid = {$id}")->save($dat7);
		   $date11 = M('Accountsinfo')->where("userid = {$id}")->find();
		   $cp['number'] = date("Ymd").rand(100000,999999);
		   $cp['type'] = '7';
		   $cp['shou_money'] = $hong;
		   $cp['zhi_money'] = 0;
		   $cp['ky_money'] = $date11['money'];
		   $cp['ctime'] = time();
		   $cp['uid'] = $id;
		   $cp['remark'] = '活动礼金';
		   M("jiaoyi")->add($cp);
		   echo 1,$hong;
		}else{
		   $id = $_SESSION['user_id'];
		   if($id){
			   $Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money")->find();
		   }

         //今日投注
		   //条件
		   $where1 = array();
		   $where1['uid'] = $id;
		   $stime1 = date('Y-m-d',time())." 09:30:00";//当天开始时间
		   $etime1 = date('Y-m-d',time())." 23:50:00";//当天结束时间
		   $stimes1 = strtotime($stime1);
		   $etimes1 = strtotime($etime1);
		   $where1['ctime'] = array(array('egt',$stimes1),array('elt',$etimes1));
		   //查表
		   $data11 = M('lottery_add')->where($where1) ->select();
		   $data21 = M('lottery_11x5')->where($where1)->select();
		   $data31 = M('lottery_fc3d')->where($where1)->select();
		   $data41 = M('lottery_kl8')->where($where1) ->select();
		   $data51 = M('lottery_pk10')->where($where1)->select();
		   $data61 = M('lottery_ssc')->where($where1)->select();
		   $data1 = array_merge($data11,$data21,$data31,$data41,$data51,$data61);
		   $touzhus1 = 0;   //投注钱数
		   foreach($data1 as $v){
			   $touzhus1 += $v["money"];
		   }
		   $touzhu1 = sprintf("%.2f", $touzhus1);

       //先到先得 begion
		   if($id==""){

		   }else {
			   $up_level4 = M('up_level')->where("uid = {$id} and type='4'")->find();
		   }


		   //条件1  上半场
		   $stime12 = date('Y-m-d',time())."  08:30:00";
		   $etime12 = date('Y-m-d',time())."  12:30:00";
		   $stimes12 = strtotime($stime12);
		   $etimes12 = strtotime($etime12);
		   $first1 = M("firstcome")->where("{$stimes12} <= lq_time and lq_time <= {$etimes12}")->select();
		   $count = count($first1);


		   //条件1  下半场
		   $stime13 = date('Y-m-d',time())."  15:00:00";
		   $etime13 = date('Y-m-d',time())."  22:30:00";
		   $stimes13 = strtotime($stime13);
		   $etimes13 = strtotime($etime13);
		   $first2 = M("firstcome")->where("{$stimes13} <= lq_time and lq_time <= {$etimes13}")->select();
		   $count2 = count($first2);
		   $timess = time();

		   //end

		   $this->assign("timess",$timess);//下半场时间判断
		   $this->assign("etimes13",$etimes13);//下半场时间判断
		   $this->assign("stimes13",$stimes13);//下半场时间判断
		   $this->assign("etimes12",$etimes12);//上半场时间判断
		   $this->assign("stimes12",$stimes12);//上半场时间判断
		   $this->assign("count2",$count2);//下半场数量判断
		   $this->assign("count",$count);   //上半场数量判断
		   $this->assign("Accountsinfo",$Accountsinfo);
		   $this->assign("touzhu1",$touzhu1);
		   $this->assign("arr4",$up_level4);
		   $this->assign("id",$id);
		   $this->display();
	   }
   }
//生日红包
   public function shengrihongbao(){
	if($_POST) {
		$id = $_SESSION['user_id'];
		if ($id) {
			$Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money")->find();
		}
		$type = I("type");
		$up = M('up_level')->where("uid = {$id} and type={$type}")->field("is_lingqu")->find();
		if ($up['is_lingqu'] == 1) {
			echo 2;die;
		}
		//生日红包奖励
		$hongbao = I("shengri");
		$dat4['kl_money'] = $hongbao;
		$dat4['is_lingqu'] = 1;
		$dat4['lq_time'] = time();
		M("up_level")->where("uid={$id} and type={$type}")->save($dat4);
		//生日红包改变money
		$up_level2 = M('up_level')->where("uid = {$id} and type={$type}")->find();
		$dat5['money'] = $Accountsinfo['money'] + $up_level2['kl_money'];
		M('Accountsinfo')->where("userid = {$id}")->save($dat5);
		$date11 = M('Accountsinfo')->where("userid = {$id}")->find();
		$cp['number'] = date("Ymd") . rand(100000, 999999);
		$cp['type'] = '7';
		$cp['shou_money'] = $hongbao;
		$cp['zhi_money'] = 0;
		$cp['ky_money'] = $date11['money'];
		$cp['ctime'] = time();
		$cp['uid'] = $id;
		$cp['remark'] = '活动礼金';
		M("jiaoyi")->add($cp);
		echo 1, $hongbao;
	}else{
		$id = $_SESSION['user_id'];
		if($id==""){

		}else {
			$up_level11 = M('up_level')->where("uid = {$id} and type='1'")->find();
		}

		if($id){
			$Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("birth")->find();
		}

		$birth = $Accountsinfo['birth'];

		$births = strtotime($birth);//581353200

		$birth1 = date("m-d",$births);//06-04

		$time = date('m-d',time()); //09-06

		if($birth1==$time){
			if($id){
				$up_level = M('up_level')->where("uid = {$id} and type='6'")->find();
			}
		}else{
			$up_level = NULL;
		}

		$stime111 = date('Y-m-d',time())." 00:00:00";
		$etime111 = date('Y-m-d',time())." 23:59:59";
		$stimes111 = strtotime($stime111);
		$etimes111 = strtotime($etime111);


		//生日红包
		$hongbao = 0;
		if($up_level['level']=='5'){
			$hongbao1 = '38';
			$hongbao  = sprintf("%.2f", $hongbao1);
		}elseif($up_level['level']=='6'){
			$hongbao2 = '58';
			$hongbao  = sprintf("%.2f", $hongbao2);
		}elseif($up_level['level']=='7'){
			$hongbao3 = '88';
			$hongbao  = sprintf("%.2f", $hongbao3);
		}elseif($up_level['level']=='8'){
			$hongbao4 = '188';
			$hongbao  = sprintf("%.2f", $hongbao4);
		}elseif($up_level['level']=='9'){
			$hongbao5 = '888';
			$hongbao  = sprintf("%.2f", $hongbao5);
		}
		//end
		$this->assign("etimes111",$etimes111);
		$this->assign("stimes111",$stimes111);
		$this->assign("etime111",$etime111);
		$this->assign("stime111",$stime111);
		$this->assign("hongbao",$hongbao);
		$this->assign("birth",$birth);
		$this->assign("Accountsinfo",$Accountsinfo);
		$this->assign("arr",$up_level);
		$this->assign("arr1",$up_level11);
		$this->assign("id",$id);
		$this->display();
	}
}
//充值回赠
   public function chongzhihuizeng(){
	   if($_POST) {
		   $id = $_SESSION['user_id'];
		   if($id){
			   $Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money")->find();
		   }

		   $type = I("type");
		   $up = M('up_level')->where("uid = {$id} and type={$type}")->field("is_lingqu")->find();
		   if($up['is_lingqu'] == 1){
			   echo 12;die;
		   }

		   //充值奖励
		   $huizeng = I("huizeng");
		   $dat61['kl_money'] = $huizeng;
		   $dat61['is_lingqu'] = 1;
		   $dat61['lq_time'] = time();
		   M("up_level")->where("uid={$id} and type={$type}")->save($dat61);

		   //充值奖励改变money
		   $up_level31 = M('up_level')->where("uid = {$id} and type={$type}")->find();
		   $dat71['money'] = $Accountsinfo['money'] + $up_level31['kl_money'];
		   M('Accountsinfo')->where("userid = {$id}")->save($dat71);
		   $date112 = M('Accountsinfo')->where("userid = {$id}")->find();
		   $cp['number'] = date("Ymd").rand(100000,999999);
		   $cp['type'] = '7';
		   $cp['shou_money'] = $huizeng;
		   $cp['zhi_money'] = 0;
		   $cp['ky_money'] = $date112['money'];
		   $cp['ctime'] = time();
		   $cp['uid'] = $id;
		   $cp['remark'] = '活动礼金';
		   M("jiaoyi")->add($cp);
		   echo 1,$huizeng;
	   }else{
		   $id = $_SESSION['user_id'];
//充值回赠 begion
		   if($id==""){}else {
			   $chongzhi = M('up_level')->where("uid = {$id} and type='5'")->find();
			   $jiaoyi = M("jiaoyi")->where("uid={$id} and type=1")->select();
		   }

		   $jiaoyi1 = array_slice($jiaoyi,-1,1);
		   foreach($jiaoyi1 as $v){
			   $shou_money = $v['shou_money'];
		   }
		   $shou_money  = sprintf("%.2f", $shou_money);
		   //可得嘉奖
		   $huizeng = 0;
		   if($chongzhi['level']==3 && 100<= $shou_money){
			   $chongzhi1 = $shou_money * 0.006;
			   $huizeng  = sprintf("%.2f", $chongzhi1);
		   }elseif($chongzhi['level']==4 && 100<= $shou_money){
			   $chongzhi2 = $shou_money * 0.007;
			   $huizeng  = sprintf("%.2f", $chongzhi2);
		   }elseif($chongzhi['level']==5 && 100<= $shou_money){
			   $chongzhi3 = $shou_money * 0.008;
			   $huizeng  = sprintf("%.2f", $chongzhi3);
		   }elseif($chongzhi['level']==6 && 100<= $shou_money){
			   $chongzhi4 = $shou_money * 0.009;
			   $huizeng  = sprintf("%.2f", $chongzhi4);
		   }elseif($chongzhi['level']==7 && 100<= $shou_money){
			   $chongzhi5 = $shou_money * 0.010;
			   $huizeng  = sprintf("%.2f", $chongzhi5);
		   }elseif($chongzhi['level']==8 && 100<= $shou_money){
			   $chongzhi6 = $shou_money * 0.011;
			   $huizeng  = sprintf("%.2f", $chongzhi6);
		   }elseif($chongzhi['level']==9 && '100'<= $shou_money){
			   $chongzhi7 = $shou_money * 0.012;
			   $huizeng  = sprintf("%.2f", $chongzhi7);
		   }
		   $this->assign("chongzhi",$chongzhi);
		   $this->assign("shou_money",$shou_money);
		   $this->assign("huizeng",$huizeng);
		   $this->assign("id",$id);
		   $this->display();
	   }


   }

//推广好礼

  public function tuiguang(){
	  if($_POST) {
		  $id = $_SESSION['user_id'];
		  if($id){
			  $Accountsinfo = M('Accountsinfo')->where("userid = {$id}")->field("money")->find();
		  }
		  $type = I("type");
		  $up = M('up_level')->where("uid = {$id} and type={$type}")->field("is_lingqu")->find();
		  if($up['is_lingqu'] == 1){
			  echo 13;die;
		  }

		  //推广奖励
		  $tuiguang = I("tuiguang");
		  $dat62['kl_money'] = $tuiguang;
		  $dat62['is_lingqu'] = 1;
		  $dat62['lq_time'] = time();
		  M("up_level")->where("uid={$id} and type={$type}")->save($dat62);

		  //推广奖励改变money
		  $up_level32 = M('up_level')->where("uid = {$id} and type={$type}")->find();
		  $dat72['money'] = $Accountsinfo['money'] + $up_level32['kl_money'];
		  M('Accountsinfo')->where("userid = {$id}")->save($dat72);
		  $date113 = M('Accountsinfo')->where("userid = {$id}")->find();
		  $cp['number'] = date("Ymd").rand(100000,999999);
		  $cp['type'] = '7';
		  $cp['shou_money'] = $tuiguang;
		  $cp['zhi_money'] = 0;
		  $cp['ky_money'] = $date113['money'];
		  $cp['ctime'] = time();
		  $cp['uid'] = $id;
		  $cp['remark'] = '活动礼金';
		  M("jiaoyi")->add($cp);
		  echo 1,$tuiguang;
	  }else{
		  $id = $_SESSION['user_id'];

		  if($id==""){

		  }else {
			  $tuiguang = M('up_level')->where("uid = {$id} and type='7'")->find();
			  $agent = M("agent")->where("uid={$id}")->field("code")->select();//查邀请码
		  }

		  foreach($agent as $v){
			  $code[] = $v["code"];
		  }
		  $codes = implode(",",$code);
		  //查找所有code下注册的账号
		  if(!empty($codes)){
			  $Accountsinfo1 = M('Accountsinfo')->where("yq_code in($codes)")->field("score")->select();
		  }
		  $zong = 0;
		  foreach($Accountsinfo1 as $v){
			  $zong += $v['score'];
		  }

		  if($zong>=500){
			  $ling = 18;
		  }
		  if($zong>=5000){
			  $ling = 58;
		  }
		  $this->assign("id",$id);
		  $this->assign("ling",$ling);
		  $this->assign("tuiguang",$tuiguang);
		  $this->display();
	  }
  }



	public function AppDownload(){
		$this->display();
	}
	public function lotteryHall(){
		$this->display();
	}
	//退出
	public function logout(){
		session(null);
		$this->display("login");
	}
	public function login(){
		$this->display();
	}
	public function dologin(){
		$where['Accounts'] = I("username");
		$pa = I("pwd");
		$data = M('Accountsinfo')
        ->where($where)
        ->find();
		if($data){
			if(trim($data['logonpass'])==$pa){
				session("user_id",$data['userid']);
				session("user_name",$data['nickname']);
				session("login_name",$data['accounts']);
				session("last_time",$data['lasttime']);
				$t = date("Y-m-d H:i:s");
				M('Accountsinfo')->where("userid = '{$data['userid']}'")->save(array("lasttime"=>$t));
				echo 3;
			}else{
				echo 2;
			}
		}else{
			echo 1;
		}
	}
	public function register(){
		$this->display();
	}

	//提现
	public function withdraw(){
		$uid = $_SESSION['user_id'];
		$res = M('Accountsinfo')->where("userid = '$uid'")->field("money,sheng_money")->find();//余额
		$ban = M("bankcard")->where("uid = '$uid'")->order("id desc")->select(); //账户里添加的银行卡
		$start = strtotime(date("Y-m-d")." 00:00:00");//开始时间
		$end = strtotime(date("Y-m-d")." 23:59:59"); //结束时间
		$co = M("tixian")->where("ctime >= $start and ctime <= $end")->count();//今天提现的次数

		foreach($ban as $ka=>$va){
			$ban[$ka]['card'] = "*******".substr(trim($va['card']),-4);
			$ban[$ka]['uname'] = "**".mb_substr(trim($va['uname']),-2,2,'utf-8');
		}

		//投注的钱数
		$touzhu = M("jiaoyi")->where("uid={$uid} and type=3")->order("id asc")->select();
		$touzhus1 = 0;
		foreach($touzhu as $k2=>$v2){
			$haha[] = $v2['zhi_money'];
			$ctime[] = $v2['ctime'];
		}
		foreach($haha as $v3){
			$touzhus1 += $v3;
		}

		if($touzhus1>=$res['sheng_money'] && $res['sheng_money']=='.0000'){
			$keti = $res['money'];
		}else{
			$keti = 0;
		}

		$this->assign("cc",$keti);
		$this->assign("res",$res);
		$this->assign("ban",$ban);
		$this->assign("co",$co);
		$this->display();
	}
	//添加 提现
	public function tx_do(){
		$data = array(
				'numbers' => 'TX'.date(md).time(),
				'uid' => $_SESSION['user_id'],
				'money' => $_POST['money'],
				'bank_id' => $_POST['aid'],
				'ctime' => time()
		);
//		dump($data);die;
		$safep = I("safep");
		$res = M("accountsinfo")->where("userid = '{$data['uid']}' and insurepass = '{$safep}'")->find();

		if(empty($res)){
			echo 2;die;
		}
		M("tixian")->add($data);
		$mm = M('Accountsinfo')->where("userid = '{$data['uid']}'")->field("money")->find();
		$cp['number'] = "TX".date(md).time();
		$cp['type'] = '2';
		$cp['zhi_money'] = $data['money'];
		$cp['ky_money'] = $mm['money'] - $data['money'];
		$cp['ctime'] = time();
		$cp['uid'] = $data['uid'];
		$cp['remark'] = '提现扣款';
		M("jiaoyi")->add($cp);
		M('Accountsinfo')->where("userid = '{$data['uid']}'")->setDec("money",$data['money']); //setInc()：将数字字段值增加 setDec()：将数字字段值减少
		echo 1;
	}


	//登录忘记密码  找回
	public function resetWay(){
		$user = I("user");
		$date = M('Accountsinfo')->where("accounts = '{$user}'")->find();
		$dat = M("answer")->where("uid=".$date['userid'])->select();
		$this->assign("dat",$dat);
		$this->assign("date",$date);
		$this->display();
	}
//修改安全密码 确认原安全密码
	function verifySafePwd(){
		if(IS_POST){
			$id = I("id");
			$pass = trim(I("pass"));
			$data= M('Accountsinfo')->where("userid='{$id}'")->field("insurepass")->find();
			if($pass == trim($data["insurepass"])){
				echo 0;
			}else{
				echo 1;
			}
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}
//修改密码
	function verifyPwd2(){
		if(IS_POST){
			$id = I("id");
			$data["LogonPass"] = I("pass");
			M('Accountsinfo')->where("userid='{$id}'")->save($data);
			echo 1;
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}
	function setMobile(){
		if(IS_POST){
			$id = I("id");
			$yzm = I("yzm");
			$shouji = I("mobile");

			$aa = M('Accountsinfo')->where("userid={$id}")->find();
            if(trim($aa['mobile']) == ""){
				echo 3;
			}
			$yanzheng = M("code")->where("mobile='{$shouji}' and code='{$yzm}'")->find();
			if($yanzheng){
				echo 1;
			}else{
				echo 2;
			}
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}

	function examine_message(){
		$mobile = I("mobile");
		$code = yz(6);
		$date = array();
		$date['mobile'] = $mobile;
		$date['code'] = $code;
		$date['ctime'] = time();
		M("code")->add($date);


		//调用类
		include ('./public/duanxin/smsapi.class.php');
		//接口账号
		$uid = 'shifencai';
		//登录密码
		$pwd = 'www123';

		/**
		 * 实例化接口
		 *
		 * @param string $uid 接口账号
		 * @param string $pwd 接口密码
		 */
		$api = new \SmsApi($uid,$pwd);

		//短信内容
		$content = '您的验证码是：'.$code.'，有效期为5分钟！【十分彩网】';
		//发送全文模板短信
		$result = $api->sendAll($mobile,$content);

		if($result['stat']=='100')
		{
			echo 1;
		}else{
			echo 2;
		}
	}

// 发送验证码到邮箱
	function examine_message2(){
		$email = I("email");
		$code = yz(6);
		$date = array();
		$date['email'] = $email;
		$date['code'] = $code;
		$date['ctime'] = time();
		M("code")->add($date);
		$title = "邮箱发送验证码";
		$content = '您的验证码是：'.$code.'，有效期为5分钟！【十分彩网】';
		sendmail($email,$title,$content);
		echo 1;
	}
//验证邮箱
	function setMail(){
		if(IS_POST){
			$id = I("id");
			$email = I("email");
			$yzm = I("yzm");
			$aa = M('Accountsinfo')->where("userid={$id}")->find();
			if(trim($aa['email']) == ""){
				echo 3;
			}
			$yanzheng = M("code")->where("email='{$email}' and code='{$yzm}'")->find();
			if($yanzheng){
				echo 1;
			}else{
				echo 2;
			}
		}else{
			$id = I("id");
			$this->assign("id",$id);
			$this->display();
		}
	}

//验证密保问题
	function verifyQuestion(){
		if(IS_POST){
			$id = I("id");
			$question1 = I("question1");
			$answer1 = I("anser1");
			$question2 = I("question2");
			$answer2 = I("anser2");
			$question3 = I("question3");
			$answer3 = I("anser3");

			$us1 = M("answer")->where(" uid={$id} and qid = {$question1} and answer = {$answer1}")->field("qid,answer")->find();
			if($us1){
				echo 1;
			}else{
				echo 2;
			}
			$us2 = M("answer")->where(" uid={$id} and qid = {$question2} and answer = {$answer2}")->field("qid,answer")->find();
			if($us2){
				echo 1;
			}else{
				echo 2;
			}
			$us3 = M("answer")->where(" uid={$id} and qid = {$question3} and answer = {$answer3}")->field("qid,answer")->find();
			if($us3){
				echo 1;
			}else{
				echo 2;
			}
		}else{
			$id = I("id");
			$date =  M("answer")->where("uid = {$id}")->select();
			foreach($date as $v){
				$qid[] = $v["qid"];
			}
			$qids = implode(",",$qid);
			if($qids){
				$quest = M("question")->where("id in($qids)")->select();
			}
//var_dump($quest);die;
			$this->assign("date",$date);
			$this->assign("arr",$quest);
			$this->assign("id",$id);
			$this->display();
		}
	}

//追号计划
   public function zhui(){
	$uid = $_SESSION['user_id'];
	if(!empty($uid)) {
      $lottery_class = M("lottery_class")->field("id")->select();
	  $this->assign("lottery_class",$lottery_class);
	  $this->display();
	}else{
		$this->display('login');
	}
}

   public function zhui_k3(){
	   $uid = $_SESSION['user_id'];
	   $lottery_class_id = I("id"); //彩种ID
	   $lottery_class = M("lottery_class")->where("id={$lottery_class_id}")->field("name")->find();

	   if($lottery_class_id==1){
		   $arr = $this->get_data("jsk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=1")->order("id desc")->limit(4)->select();
		   $he = M("jihua_jsk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_jsk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_jsk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==2){
		   $arr = $this->get_data("ahk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=2")->order("id desc")->limit(4)->select();
		   $he = M("jihua_ahk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_ahk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_ahk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==3){
		   $arr = $this->get_data("gxk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=3")->order("id desc")->limit(4)->select();
		   $he = M("jihua_gxk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_gxk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_gxk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
       }elseif($lottery_class_id==4){
		   $arr = $this->get_data("hubk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=4")->order("id desc")->limit(4)->select();
		   $he = M("jihua_hubk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_hubk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_hubk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==5){
		   $arr = $this->get_data("bjk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=5")->order("id desc")->limit(4)->select();
		   $he = M("jihua_bjk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_bjk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_bjk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==9){
		   $arr = $this->get_data("hebk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=9")->order("id desc")->limit(4)->select();
		   $he = M("jihua_hebk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_hebk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_hebk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==10){
		   $arr = $this->get_data("gsk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=10")->order("id desc")->limit(4)->select();
		   $he = M("jihua_gsk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_gsk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_gsk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==11){
		   $arr = $this->get_data("shk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=11")->order("id desc")->limit(4)->select();
		   $he = M("jihua_shk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_shk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_shk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==12){
		   $arr = $this->get_data("gzk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=12")->order("id desc")->limit(4)->select();
		   $he = M("jihua_gzk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_gzk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_gzk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }elseif($lottery_class_id==13){
		   $arr = $this->get_data("jlk3");
		   $res = M("lottery_add")->where("uid = $uid and lotteryclass=13")->order("id desc")->limit(4)->select();
		   $he = M("jihua_jlk3")->order("id desc")->limit(10)->select();
		   $size = M("jihua_jlk3_size")->order("id desc")->limit(10)->select();
		   $attr = M("jihua_jlk3_attr")->order("id desc")->limit(10)->select();
		   $tt = array();
		   $tt1 = array();
		   $tt2 = array();
		   foreach($he as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt[] = substr($va,-3);
			   }
			   if(count($tt)>1){
				   $he[$k]['iss'] = $tt[0]."-".$tt[1];
			   }else{
				   $he[$k]['iss'] = $tt[0];
			   }
			   $tt = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $he[$k]['sta'] = $zz1;
		   }
		   foreach($size as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt1[] = substr($va,-3);
			   }
			   if(count($tt1)>1){
				   $size[$k]['iss'] = $tt1[0]."-".$tt1[1];
			   }else{
				   $size[$k]['iss'] = $tt1[0];
			   }
			   $tt1 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $size[$k]['sta'] = $zz1;
		   }
		   foreach($attr as $k=>$v){
			   $cc = explode("-",trim($v['issue']));
			   foreach($cc as $ka=>$va){
				   $tt2[] = substr($va,-3);
			   }
			   if(count($tt2)>1){
				   $attr[$k]['iss'] = $tt2[0]."-".$tt2[1];
			   }else{
				   $attr[$k]['iss'] = $tt2[0];
			   }
			   $tt2 = array();
			   $zz = explode(",",$v['status']);
			   $zz1 = array_filter($zz);
			   $attr[$k]['sta'] = $zz1;
		   }
	   }
	   $this->assign("arr",$arr);
	   $this->assign("res",$res);
	   $this->assign("he",$he);
	   $this->assign("size",$size);
	   $this->assign("attr",$attr);
	   $this->assign("lottery_class_id",$lottery_class_id);
	   $this->assign('lottery_class',$lottery_class);
	   $this->display();
   }

	public function zhui_ssc(){
		$uid = $_SESSION['user_id'];
		$lottery_class_id = I("id"); //彩种ID
		$lottery_class = M("lottery_class")->where("id={$lottery_class_id}")->field("name")->find();
		if($lottery_class_id==15){
			$arr = $this->get_data("cqssc");
			$res = M("lottery_ssc")->where("uid = $uid and lotteryclass=13")->order("id desc")->limit(4)->select();
			$gw = M("jihua_ssc_gw")->order("id desc")->limit(10)->select();
			$sw = M("jihua_ssc_sw")->order("id desc")->limit(10)->select();
			$bw = M("jihua_ssc_bw")->order("id desc")->limit(10)->select();
			$qw = M("jihua_ssc_qw")->order("id desc")->limit(10)->select();
			$ww = M("jihua_ssc_ww")->order("id desc")->limit(10)->select();
			$tt = array();
			$tt1 = array();
			$tt2 = array();
			foreach($gw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt[] = substr($va,-3);
				}
				if(count($tt)>1){
					$gw[$k]['iss'] = $tt[0]."-".$tt[1];
				}else{
					$gw[$k]['iss'] = $tt[0];
				}
				$tt = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$gw[$k]['sta'] = $zz1;
			}
			foreach($sw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$sw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$sw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$sw[$k]['sta'] = $zz1;
			}
			foreach($bw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$bw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$bw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$bw[$k]['sta'] = $zz1;
			}
			foreach($qw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$qw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$qw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$qw[$k]['sta'] = $zz1;
			}
			foreach($ww as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$ww[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$ww[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$ww[$k]['sta'] = $zz1;
			}
		}elseif($lottery_class_id==17){
			$arr = $this->get_data("xjssc");
			$res = M("lottery_ssc")->where("uid = $uid and lotteryclass=17")->order("id desc")->limit(4)->select();
			$gw = M("jihua_xjssc_gw")->order("id desc")->limit(10)->select();
			$sw = M("jihua_xjssc_sw")->order("id desc")->limit(10)->select();
			$bw = M("jihua_xjssc_bw")->order("id desc")->limit(10)->select();
			$qw = M("jihua_xjssc_qw")->order("id desc")->limit(10)->select();
			$ww = M("jihua_xjssc_ww")->order("id desc")->limit(10)->select();
			$tt = array();
			$tt1 = array();
			$tt2 = array();
			foreach($gw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt[] = substr($va,-3);
				}
				if(count($tt)>1){
					$gw[$k]['iss'] = $tt[0]."-".$tt[1];
				}else{
					$gw[$k]['iss'] = $tt[0];
				}
				$tt = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$gw[$k]['sta'] = $zz1;
			}
			foreach($sw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$sw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$sw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$sw[$k]['sta'] = $zz1;
			}
			foreach($bw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$bw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$bw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$bw[$k]['sta'] = $zz1;
			}
			foreach($qw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$qw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$qw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$qw[$k]['sta'] = $zz1;
			}
			foreach($ww as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$ww[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$ww[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$ww[$k]['sta'] = $zz1;
			}
		}elseif($lottery_class_id==18){
			$arr = $this->get_data("tjssc");
			$res = M("lottery_ssc")->where("uid = $uid and lotteryclass=18")->order("id desc")->limit(4)->select();
			$gw = M("jihua_tjssc_gw")->order("id desc")->limit(10)->select();
			$sw = M("jihua_tjssc_sw")->order("id desc")->limit(10)->select();
			$bw = M("jihua_tjssc_bw")->order("id desc")->limit(10)->select();
			$qw = M("jihua_tjssc_qw")->order("id desc")->limit(10)->select();
			$ww = M("jihua_tjssc_ww")->order("id desc")->limit(10)->select();
			$tt = array();
			$tt1 = array();
			$tt2 = array();
			foreach($gw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt[] = substr($va,-3);
				}
				if(count($tt)>1){
					$gw[$k]['iss'] = $tt[0]."-".$tt[1];
				}else{
					$gw[$k]['iss'] = $tt[0];
				}
				$tt = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$gw[$k]['sta'] = $zz1;
			}
			foreach($sw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$sw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$sw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$sw[$k]['sta'] = $zz1;
			}
			foreach($bw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$bw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$bw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$bw[$k]['sta'] = $zz1;
			}
			foreach($qw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$qw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$qw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$qw[$k]['sta'] = $zz1;
			}
			foreach($ww as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$ww[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$ww[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$ww[$k]['sta'] = $zz1;
			}
		}elseif($lottery_class_id==19){
			$arr = $this->get_data("ffc2");
			$res = M("lottery_ssc")->where("uid = $uid and lotteryclass=19")->order("id desc")->limit(4)->select();
			$gw = M("jihua_ajssc_gw")->order("id desc")->limit(10)->select();
			$sw = M("jihua_ajssc_sw")->order("id desc")->limit(10)->select();
			$bw = M("jihua_ajssc_bw")->order("id desc")->limit(10)->select();
			$qw = M("jihua_ajssc_qw")->order("id desc")->limit(10)->select();
			$ww = M("jihua_ajssc_ww")->order("id desc")->limit(10)->select();
			$tt = array();
			$tt1 = array();
			foreach($gw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt[] = substr($va,-3);
				}
				if(count($tt)>1){
					$gw[$k]['iss'] = $tt[0]."-".$tt[1];
				}else{
					$gw[$k]['iss'] = $tt[0];
				}
				$tt = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$gw[$k]['sta'] = $zz1;
			}
			foreach($sw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$sw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$sw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$sw[$k]['sta'] = $zz1;
			}
			foreach($bw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$bw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$bw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$bw[$k]['sta'] = $zz1;
			}
			foreach($qw as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$qw[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$qw[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$qw[$k]['sta'] = $zz1;
			}
			foreach($ww as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt1[] = substr($va,-3);
				}
				if(count($tt1)>1){
					$ww[$k]['iss'] = $tt1[0]."-".$tt1[1];
				}else{
					$ww[$k]['iss'] = $tt1[0];
				}
				$tt1 = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$ww[$k]['sta'] = $zz1;
			}
		}

		$this->assign("arr",$arr);
		$this->assign("res",$res);
		$this->assign("gw",$gw);
		$this->assign("sw",$sw);
		$this->assign("bw",$bw);
		$this->assign("qw",$qw);
		$this->assign("ww",$ww);
		$this->assign("lottery_class_id",$lottery_class_id);
		$this->assign('lottery_class',$lottery_class);
		$this->display();
	}


	public function zhui_pk10(){
		$uid = $_SESSION['user_id'];
		$lottery_class_id = I("id"); //彩种ID
		$lottery_class = M("lottery_class")->where("id={$lottery_class_id}")->field("name")->find();
		if($lottery_class_id==21){
			$arr = $this->get_data("bjpk10");
			$uid = $_SESSION['user_id'];
			$res = M("lottery_pk10")->where("uid = $uid and lotteryclass=21")->order("id desc")->limit(4)->select();
			$he = M("jihua_pk10")->order("id desc")->limit(10)->select();
			$tt = array();
			foreach($he as $k=>$v){
				$cc = explode("-",trim($v['issue']));
				foreach($cc as $ka=>$va){
					$tt[] = substr($va,-3);
				}
				if(count($tt)>1){
					$he[$k]['iss'] = $tt[0]."-".$tt[1];
				}else{
					$he[$k]['iss'] = $tt[0];
				}
				$tt = array();
				$zz = explode(",",$v['status']);
				$zz1 = array_filter($zz);
				$he[$k]['sta'] = $zz1;
			}
		}

		$this->assign("lottery_class_id",$lottery_class_id);
		$this->assign('lottery_class',$lottery_class);
		$this->assign("arr",$arr);
		$this->assign("res",$res);
		$this->assign("he",$he);
		$this->display();
	}


//获取 接口数据
	static function get_data($a){
		$url = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=".$a."&format=json&rows=10";
		$ch = curl_init();
		curl_setopt ($ch, CURLOPT_URL,$url);
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
		$file_contents = curl_exec($ch);
		curl_close($ch);
		$data = json_decode($file_contents,true);
		$arr = $data["data"];
		foreach($arr as $k=>$v){
			$arr[$k]['ocode'] = explode(",",$v['opencode']);
		}

		foreach($arr as $k=>$v){
			$m = 0;
			foreach($v['ocode'] as $kc=>$vc){
				$m+=$vc;
			}
			$arr[$k]['total'] = $m;
			if($m>=3 && $m<=10){
				$arr[$k]['size'] = '1';//小
			}if($m>=11 && $m<=18){
				$arr[$k]['size'] = '2';//大
			}
			if($m%2!=0){
				$arr[$k]['attr'] = '1';//单
			}else{
				$arr[$k]['attr'] = '2';//双
			}
			//	unset($arr[$k]['ocode']);
		}
		return $arr;
	}











}